package com.iot08.common.config.mongodb.converter;

import com.iot08.common.utils.DateUtil;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.WritingConverter;

import java.util.Date;

/**
 * @version 1.0
 * @Description: mongodb 写入时Date的处理
 * @time: 2020/9/25 17:57
 * @author: Rock
 */
@WritingConverter
public class MongoDateWritingHandle implements Converter<Date, Object> {

    @Override
    public Object convert(Date source) {
        if (source != null) {
            DateUtil.hanldeMongoDate(source, 1);
            return source;
        }
        return null;
    }
}
